<!-- 商城信息配置 -->
<template>
    <div class="app-container" id="mall-container">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>运费配置</span>
        </div>
        <el-form
          :model="expressForm"
          ref="form"
          label-width="250px"
          style="margin-left: 150px"
          :rules="rules"
        >
          <el-form-item
            label="运费满减所需最低消费"
            prop="shopping_express_freight_min"
          >
            <el-input
              v-model.number="expressForm.shopping_express_freight_min"
              style="width: 700px"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="运费满减不足所需运费"
            prop="shopping_express_freight_value"
          >
            <el-input
              v-model="expressForm.shopping_express_freight_value"
              style="width: 700px"
            ></el-input>
          </el-form-item>
        </el-form>
        <span class="footer">
          <el-button type="primary" @click="handleUpdate">确 定</el-button>
          <el-button @click="handleReset">重 置</el-button>
        </span>
      </el-card>
    </div>
  </template>
  <script >
  import { listExpress, updateExpress } from "@/api/config/express.js";
  export default {
    data() {
      return {    
        expressForm: {},
        rules: {
              shopping_express_freight_min: [
                  { required: true, message: '运费配置不能为空', trigger: 'blur' },
              ],
              shopping_express_freight_value: [
                  { required: true, message: '运费配置不能为空', trigger: 'blur' }
              ],
          }
      };
    },
    components: {},
    created() {
      this.getData();
    },
    mounted() {},
    methods: {
      handleCancel() {
        this.getData();
        this.$message({
          message: "已取消",
        });
      },
      handleReset() {
          this.getData();
          this.$message({
            message: "重置成功",
            type: "success",
          });
      },
      handleUpdate() {
          this.$refs.form.validate((valid) => {
          if (valid) {
            updateExpress(this.expressForm).then((res) => {
                this.$message({
                  message: "修改成功",
                  type: "success",
                });
                this.getData();
                this.expressForm = {};
            });
          }
        });
      },
      //获取列表数据接口
      getData() {
        listExpress().then((res) => {
          this.expressForm = res.data.data;
        });
      },
    },
  };
  </script>
  <style rel="stylesheet/scss" lang='scss' scoped>
  .footer {
    float: right;
    margin-bottom: 20px;
  }
  </style>
  <style scoped>
  </style>
  